<template>
  <div class="block">
    <el-carousel trigger="click" height="350px">
      <el-carousel-item v-for="information in informations" :key="information.slides_id">
        <img :src="information.img" class="image" @click="informationDetail(information.slides_id)">
      </el-carousel-item>
    </el-carousel>
  </div>
</template>
<script>
import axios from 'axios';
export default {
  data() {
    return {
      informations: []
    }
  },
  methods: {
    informationDetail(id) {
      this.$router.push({ name: 'information_detail', params: { article_id: id } }, () => { }, () => { });
    },
  },
  created: function () {
    if (this.$route.params.isLogin) {
      window.location.reload();
    }
    let that = this;
    axios.get('http://127.0.0.1:5000/api/slides/get_list', {
      params: {
        page: 1,
        size: 4
      }
    })
      .then(function (response) {
        console.log(response.data.result);
        that.informations = response.data.result.list;
      })
      .catch(function (error) {
        console.log(error);
      })
      .then(function () {
        // 总是会执行
      })
  }
}
</script>
<style lang="less" scoped></style>